<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: GlobalChannelService</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: GlobalChannelService</h1>

    




<section>

<header>
    
        <h2>GlobalChannelService</h2>
        
            <div class="class-description">Global channel service.
GlobalChannelService is created by globalChannel component which is a default
component of pomelo enabled by `app.set('globalChannelConfig', {...})`
and global channel service would be accessed by
`app.get('globalChannelService')`.</div>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    
    <h2>Constructor</h2>
    

    <h4 class="name" id="GlobalChannelService"><span class="type-signature"></span>new GlobalChannelService<span class="signature">(app, opts)</span><span class="type-signature"></span></h4>

    



<div class="description">
    构造函数
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>app</code></td>
            

            <td class="type">
            
                
<span class="param-type">*</span>


            
            </td>

            

            

            <td class="description last">pomelo instance</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>opts</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">参数列表</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line20">line 20</a>
    </li></ul></dd>
    

    

    

    
</dl>
















    
    </div>

    

    

    

     

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    <h4 class="name" id="add"><span class="type-signature"></span>add<span class="signature">(uid, sid, channelName)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    添加一个玩家 到指定channelName
Add a member into channel.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>uid</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">user id</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sid</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">frontend server id</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>channelName</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>
|

<span class="param-type">Array</span>


            
            </td>

            

            
                <td class="default">
                
                    null
                
                </td>
            

            <td class="description last">指定的 channelName</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line268">line 268</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    is add: 1 add success, 0 fail
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">number</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="destroyChannel"><span class="type-signature"></span>destroyChannel<span class="signature">(channelName)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Destroy a global channel.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>channelName</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">global channel name</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line253">line 253</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id="getMembersBySid"><span class="type-signature"></span>getMembersBySid<span class="signature">(channelName, frontId)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Get members by frontend server id.
获取指定服务器和channelName 的玩家列表
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>channelName</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">channel name</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>frontId</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">frontend server id</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line173">line 173</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id="getSidsByUid"><span class="type-signature"></span>getSidsByUid<span class="signature">(uid)</span><span class="type-signature"> &rarr; {Array}</span></h4>

    



<div class="description">
    获得指定玩家在所在的服务器
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>uid</code></td>
            

            <td class="type">
            
            </td>

            

            

            <td class="description last">要查找的 玩家id</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line185">line 185</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Array</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="getSidsByUidArr"><span class="type-signature"></span>getSidsByUidArr<span class="signature">(uidArr)</span><span class="type-signature"> &rarr; {Object}</span></h4>

    



<div class="description">
    获取指定玩家的服务器列表
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>uidArr</code></td>
            

            <td class="type">
            
            </td>

            

            

            <td class="description last">要查找的玩家列表</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line197">line 197</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="leave"><span class="type-signature"></span>leave<span class="signature">(uid, sid, channelName)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Remove user from channel.
移除一个玩家
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>uid</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">user id</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sid</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">frontend server id</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>channelName</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>
|

<span class="param-type">Array</span>


            
            </td>

            

            
                <td class="default">
                
                    null
                
                </td>
            

            <td class="description last">channel name</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line283">line 283</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id="pushMessage"><span class="type-signature"></span>pushMessage<span class="signature">(serverType, route, msg, channelName)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Send message by global channel.
 发送消息给指定 channelName 的所有玩家
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>serverType</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">frontend server type</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>route</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">route string</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>msg</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">message would be sent to clients</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>channelName</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">channel name</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line125">line 125</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id="pushMessageByUidArr"><span class="type-signature"></span>pushMessageByUidArr<span class="signature">(uidArr, route, msg, frontServerId)</span><span class="type-signature"> &rarr; {Array}</span></h4>

    



<div class="description">
    群发消息给玩家
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>uidArr</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>
|

<span class="param-type">Array</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">要发送的玩家列表</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>route</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">消息号</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>msg</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">消息内容</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>frontServerId</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>
|

<span class="param-type">null</span>


            
            </td>

            

            
                <td class="default">
                
                    null
                
                </td>
            

            <td class="description last">指定的前端服务器Id, 默认不指定</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line69">line 69</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    send message fail userList
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Array</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="pushMessageForUid"><span class="type-signature"></span>pushMessageForUid<span class="signature">(route, uids, msg, serverType, frontServerId)</span><span class="type-signature"> &rarr; {Array}</span></h4>

    



<div class="description">
    发送消息给指定服务器 中的某一些人
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>route</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">route string</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>uids</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array</span>


            
            </td>

            

            

            <td class="description last">userId array</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>msg</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">消息内容</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>serverType</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">frontend server type</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>frontServerId</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">frontend server Id</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line45">line 45</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    send message fail userList
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Array</span>


    </dd>
</dl>

    



        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="GlobalChannelService.html">GlobalChannelService</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Fri May 05 2017 16:16:31 GMT+0800 (CST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>